/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2016 All Rights Reserved.
 */
package com.alipay.study.core.security.user;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * 
 * @author wb-qlj205528
 * @version $Id: SecurityUserDetailsService.java, v 0.1 2016年11月10日 上午11:14:54 wb-qlj205528 Exp $
 */
@Component
public class SecurityUserDetailsService implements UserDetailsService {

    /** 
     * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
     */
    public UserDetails loadUserByUsername(String arg0) throws UsernameNotFoundException {

        List<GrantedAuthority> list = new ArrayList<GrantedAuthority>();
        GrantedAuthority grante = new SimpleGrantedAuthority("ROLE_USER");
        list.add(grante);

        GrantedAuthority granteAuthority = new SimpleGrantedAuthority("USER");
        list.add(granteAuthority);

        User user = new User("admin", "admin123", list);

        return user;
    }
}
